/*
 * Ext JS Library 2.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

// Add the additional 'advanced' VTypes
Ext.apply(Ext.form.VTypes, {
    password : function(val, field) {
        if (field.initialPassField) {
            var pwd = Ext.getCmp(field.initialPassField);
            return (val == pwd.getValue());
        }
        return true;
    },

    passwordText : 'Passwords do not match'
});

Ext.onReady(function(){

    Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

    var bd = Ext.getBody();

	
    var pass_frm = new Ext.FormPanel({
        frame: true,
        title:'Your information',
        labelAlign: 'right',
        labelWidth: 120,
        width:300,        
        waitMsgTarget: true,

      
        defaultType: 'textfield',
        items: [{
                fieldLabel: 'Previous password',
                name: 'prev_pass',
                allowBlank:false,                
                width:150
                },{
                fieldLabel: 'Password',
                inputType: 'password',
                allowBlank:false,
                name: 'pass',
                id: 'pass',
                width:150
          },{
            fieldLabel: 'Confirm Password',
            inputType: 'password',
            name: 'pass-cfrm',
            vtype: 'password',
            initialPassField: 'pass', // id of the initial password field
            width:150
          }]
    });    
    
    var regSuccess = function(){
        alert('Registered');
    };
    var submit = pass_frm.addButton({
        text: 'Submit',        
        handler: function(){
            var form = pass_frm.getForm();
            if(form.isValid()){
                form.submit({url:'password', waitMsg:'Submiting...', success:regSuccess});
            }
        }
    });

    pass_frm.render('pass-form');
});